package router

import (
	"cloud-entropy-storage-system/server/internal/logic/render"
	"cloud-entropy-storage-system/server/internal/middleware"
)

func setRender(s *Server) {
	r := s.Engine
	renderLogic := render.NewRender(s.Log, s.db, s.gc, s.meta, s.manager, s.cfg)

	// 系统页
	sysPage := r
	{
		sysPage.GET("/", middleware.IsLogin, renderLogic.Index())
		sysPage.GET("/login", middleware.CheckLoginPage, renderLogic.Login())
		sysPage.GET("/logout", renderLogic.Logout())
	}

	// 用户相关页
	userPage := r.Group("/user", middleware.IsLogin)
	{
		userPage.GET("/password", renderLogic.Password())
	}

	// 文件相关页
	filePage := r.Group("/file", middleware.IsLogin)
	{
		filePage.GET("/list", renderLogic.FileList())
		filePage.GET("/upload", renderLogic.Upload())
		filePage.GET("/gallery", renderLogic.Gallery())
		filePage.GET("/video", renderLogic.Video())
	}

	// 文件夹相关页
	dirPage := r.Group("/dir", middleware.IsLogin)
	{
		dirPage.GET("/list", renderLogic.DirList())
		dirPage.GET("/form", renderLogic.DirForm())
	}
}
